#define _CRT_SECURE_NO_WARNINGS 1

#pragma once

template <class Interator, class Ref, class Ptr>
class ReverseInterator
{
public:
	typedef ReverseInterator<Interator, Ref, Ptr> Self;

	ReverseInterator(Interator it)
		: _it(it)
	{}

	Self& operator++()
	{
		--_it;
		return *this;
	}

	Self operator++(int)
	{
		auto tmp = _it;
		--_it;
		return tmp;
	}

	Self& operator--()
	{
		++_it;
		return *this;
	}

	Self operator--(int)
	{
		auto tmp = _it;
		++_it;
		return tmp;
	}

	Ref operator*()
	{
		auto tmp = _it;
		return *(--tmp);
	}

	Ptr operator->()
	{
		return &(operator*());
	}

	bool operator!=(const Self& s) const
	{
		return _it != s._it;
	}

	bool operator==(const Self& s) const
	{
		return _it == s._it;
	}

private:
	Interator _it;
};